#ifndef _SENDER_H_
#define _SENDER_H_

#include "sendererror.h"
#include "fileerror.h"

#include <QObject>
#include <QString>
#include <QUrl>

class QNetworkAccessManager;
class QNetworkReply;

namespace Avd {

class Daemon;

class Sender : public QObject {
Q_OBJECT
public:
	
	Sender(Daemon* daemon, const QString &serverUrl, const short unsigned int port);
	~Sender();

	void askLogin(const QString& user, const QString& password) throw(SenderError);
	void askLogoff(const unsigned int session,
								 const QString& username) throw(SenderError);
	void askDownload(const unsigned int session,const QString& path,
									 const QString& name, const unsigned int part = 0,
									 const unsigned int totalParts = 1) throw(SenderError);
	void askUpload(const unsigned int session, const QString& path,
								 const QString& name, const unsigned int version) throw(FileError, SenderError);
	void askList(const unsigned int session,
							 const QString& path) throw(SenderError);
	void askMove(const unsigned int session,
							 const QString& oldPath, const QString& oldName,
							 const QString& newPath, const QString& newName) throw(SenderError);
	void askDelete(const unsigned int session, const QString& path,
								 const QString& name) throw(SenderError);
	void askCreateFolder(const unsigned int session, const QString& path,
											 const QString& name) throw(SenderError);
	void askCopy(const unsigned int session,
							 const QString& path, const QString& name,
							 const QString& copyPath) throw(SenderError);
	void askVersion(const unsigned int session, const QString& path,
									const QString& name) throw(SenderError);

signals:
	void sigReply(QNetworkReply *reply);
private:
	void send(const QString& request);
	Daemon* daemon;
	QUrl serverUrl;
	const short unsigned int port;
	QNetworkAccessManager *networkManager;
};

}

#endif

